package stark.app.function.paint;

import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.vilyever.drawingview.db.DrawRecord;

import stark.app.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;

/**
 * Author：daizhongbin on 2024/5/11
 * Email：1027154338@qq.com
 * Desc:
 */
public class DrawRecordAdapter extends StkProviderMultiAdapter<DrawRecord> {

    public DrawRecordAdapter() {
        super(3);
        addItemProvider(new ItemProvider());
    }

    class ItemProvider extends BaseItemProvider<DrawRecord> {

        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_draw_record;
        }

        @Override
        public void convert(@NonNull BaseViewHolder holder, DrawRecord drawRecord) {
            ImageView ivImg = holder.getView(R.id.ivImg);
            Glide.with(ivImg).load(drawRecord.getImgFilePath()).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).into(ivImg);
            TextView tvName = holder.getView(R.id.tvName);
            tvName.setText(drawRecord.name);
        }
    }
}
